package com.menhai.personmanagement.utils;

import com.menhai.personmanagement.entity.MbPopulation;
import com.menhai.personmanagement.entity.vo.TjInspectphysicalVo;
import com.menhai.personmanagement.entity.vo.UserVo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


/**
 * @author shikun
 * @describe 导出文件类
 * @Return
 * @Date 2021/12/1 9:27
 */
public class ExportSysUserInfoExcel {

 /**
  * @describe 导出文件方法
  * @param userList
  * @param fout
  * @param resp
  * @Return void
  * @Date 2021/12/1 9:43
  * @author shikun
  */
 public void export(List<UserVo> userList, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 7);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("医生人员信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
//   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 32*256);
//   sheet.setColumnWidth(4, 10*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("人员信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(7);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"姓名", "年龄", "性别", "工号", "身份证号","科室","职务","联系方式"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (userList != null) {
    int i = 1;
    for (int j = 0; j < userList.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出
     HSSFCell cell_0 = row3.createCell(0);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(userList.get(j).getName());
     HSSFCell cell_1 = row3.createCell(1);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(userList.get(j).getAge());
     HSSFCell cell_2 = row3.createCell(2);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(userList.get(j).getSexname());
     HSSFCell cell_3 = row3.createCell(3);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(userList.get(j).getJobnumber());
     HSSFCell cell_4 = row3.createCell(4);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(userList.get(j).getIdentity());
     HSSFCell cell_5 = row3.createCell(5);
     cell_5.setCellStyle(cellStyle);
     cell_5.setCellValue(userList.get(j).getClassname());
     HSSFCell cell_6 = row3.createCell(6);
     cell_6.setCellStyle(cellStyle);
     cell_6.setCellValue(userList.get(j).getPositionname());
     HSSFCell cell_7 = row3.createCell(7);
     cell_7.setCellStyle(cellStyle);
     cell_7.setCellValue(userList.get(j).getMobile());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "医生人员信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }



 public void searchByStringId(MbPopulation mbPopulations, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 5);//起始行,结束行,起始列,结束列(输出列-1)

   CellRangeAddress callRangeAddress2 = new CellRangeAddress(1, 1, 0, 5);//起始行,结束行,起始列,结束列(输出列-1)

   CellRangeAddress callRangeAddress3 = new CellRangeAddress(2, 3, 0, 0);//起始行,结束行,起始列,结束列(输出列-1)

   CellRangeAddress callRangeAddress4 = new CellRangeAddress(4, 9, 0, 0);//起始行,结束行,起始列,结束列(输出列-1)

   CellRangeAddress callRangeAddress5 = new CellRangeAddress(4, 9, 1, 5);//起始行,结束行,起始列,结束列(输出列-1)

   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);

   HSSFCellStyle littlecolStyle = createCellStyle(workbook, (short) 12, true, true, false);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);

   HSSFCellStyle newline = workbook.createCellStyle();

   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("社区居民基本情况");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);

   sheet.addMergedRegion(callRangeAddress2);

   sheet.addMergedRegion(callRangeAddress3);

   sheet.addMergedRegion(callRangeAddress4);

   sheet.addMergedRegion(callRangeAddress5);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);

   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   cell.setCellStyle(headStyle);
   cell.setCellValue("社区居民基本情况");

   HSSFRow rowsan = sheet.createRow(1);
   HSSFCell cellsan2 = rowsan.createCell(0);
   cellsan2.setCellStyle(littlecolStyle);
   cellsan2.setCellValue("居民信息");



   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"信息","姓名","性别", "年龄", "身份证号", "联系电话"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (mbPopulations != null) {
    HSSFRow row3 = sheet.createRow(3);
    HSSFCell cell_0 = row3.createCell(1);
    cell_0.setCellStyle(cellStyle);
    cell_0.setCellValue(mbPopulations.getName());

    HSSFCell cell_1 = row3.createCell(2);
    cell_1.setCellStyle(cellStyle);
    cell_1.setCellValue(mbPopulations.getSex());

    HSSFCell cell_2 = row3.createCell(3);
    cell_2.setCellStyle(cellStyle);
    cell_2.setCellValue(mbPopulations.getAge());

    HSSFCell cell_3 = row3.createCell(4);
    cell_3.setCellStyle(cellStyle);
    cell_3.setCellValue(mbPopulations.getIdnumber());

    HSSFCell cell_4 = row3.createCell(5);
    cell_4.setCellStyle(cellStyle);
    cell_4.setCellValue(mbPopulations.getTelephony());
   }

   HSSFRow cell_4 = sheet.createRow(4);
   HSSFCell cell4san4 = cell_4.createCell(0);
   cell4san4.setCellStyle(cellStyle);
   cell4san4.setCellValue("一般情况");

   HSSFRow cell_6 = sheet.createRow(5);
   HSSFCell cell6san6 = cell_6.createCell(0);
   cell6san6.setCellStyle(cellStyle);

   HSSFRow cell_7 = sheet.createRow(6);
   HSSFCell cell7san7 = cell_7.createCell(0);
   cell7san7.setCellStyle(cellStyle);

   HSSFRow cell_8 = sheet.createRow(7);
   HSSFCell cell8san8 = cell_8.createCell(0);
   cell8san8.setCellStyle(cellStyle);

   HSSFRow cell_9 = sheet.createRow(8);
   HSSFCell cell9san9 = cell_9.createCell(0);
   cell9san9.setCellStyle(cellStyle);

   HSSFRow cell_10 = sheet.createRow(9);
   HSSFCell cell0san10 = cell_10.createCell(0);
   cell0san10.setCellStyle(cellStyle);

   HSSFCell cell5san5 = cell_4.createCell(1);
   cell5san5.setBlank();
   cell5san5.setCellStyle(cellStyle);


   String lianglao = mbPopulations.getLianglao();
   if(lianglao==null)
    lianglao="";
   String soldier = mbPopulations.getSoldier();
   if(soldier==null)
    soldier="";
   String junlieshu = mbPopulations.getJunlieshu();
   if(junlieshu==null)
    junlieshu="";
   String volunteerType = mbPopulations.getVolunteerType();
   if(volunteerType==null)
    volunteerType="";
   String diasporaType = mbPopulations.getDiasporaType();
   if(diasporaType==null)
    diasporaType="";
   String youfu = mbPopulations.getYoufu();
   if(youfu==null)
    youfu="";

   String detailed = "两劳:("+lianglao+ ")"+"\r\n "
       +"兵役情况:("+soldier+")"+"\r\n "
       +"军烈属:("+junlieshu+")"+"\r\n "
       +"志愿者:("+volunteerType+")"+"\r\n "
       +"侨务人员:("+diasporaType+")"+"\r\n "
       +"优抚:("+youfu+")";

   cell5san5.setCellValue(detailed);

   //5.输出
   try {
    //下载文件名
    String fileName = "社区居民基本情况";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 /**
  * @describe 残疾人员导出
  * @param mbPopulations
  * @param fout
  * @param resp
  * @Return void
  * @Date 2022/2/21 14:20
  * @author shikun
  */
 public void exportBydisabled(List<MbPopulation> mbPopulations, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 5);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("残疾人员统计信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
//   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 32*256);
   sheet.setColumnWidth(4, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("残疾人员信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(5);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名", "性别", "民族", "出生年月","家庭住址"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (mbPopulations != null) {
    int i = 1;
    for (int j = 0; j < mbPopulations.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出

     HSSFCell cell_5 = row3.createCell(0);
     cell_5.setCellStyle(cellStyle);
     cell_5.setCellValue(mbPopulations.get(j).getSuperiorCode());
     HSSFCell cell_0 = row3.createCell(1);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(mbPopulations.get(j).getName());
     HSSFCell cell_1 = row3.createCell(2);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(mbPopulations.get(j).getSex());
     HSSFCell cell_2 = row3.createCell(3);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(mbPopulations.get(j).getNation());
     HSSFCell cell_3 = row3.createCell(4);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(mbPopulations.get(j).getBirthday().substring(0,10));
     HSSFCell cell_4 = row3.createCell(5);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(mbPopulations.get(j).getNewaddress());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "残疾人员信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }


 /**
  * @describe 两劳人员导出
  * @param mbPopulations
  * @param fout
  * @param resp
  * @Return void
  * @Date 2022/2/21 14:21
  * @author shikun
  */
 public void selectBylianglao(List<MbPopulation> mbPopulations, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 6);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("两劳人员统计信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
//   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 32*256);
   sheet.setColumnWidth(6, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("两劳人员信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(6);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名", "性别", "年龄", "两劳","低保","家庭住址"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (mbPopulations != null) {
    int i = 1;
    for (int j = 0; j < mbPopulations.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出

     HSSFCell cell_7 = row3.createCell(0);
     cell_7.setCellStyle(cellStyle);
     cell_7.setCellValue(mbPopulations.get(j).getSuperiorCode());

     HSSFCell cell_0 = row3.createCell(1);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(mbPopulations.get(j).getName());
     HSSFCell cell_1 = row3.createCell(2);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(mbPopulations.get(j).getSex());
     HSSFCell cell_2 = row3.createCell(3);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(mbPopulations.get(j).getAge());
     HSSFCell cell_3 = row3.createCell(4);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(mbPopulations.get(j).getLianglao());
     HSSFCell cell_4 = row3.createCell(5);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(mbPopulations.get(j).getLowIncome());
     HSSFCell cell_5 = row3.createCell(6);
     cell_5.setCellStyle(cellStyle);
     cell_5.setCellValue(mbPopulations.get(j).getNewaddress());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "两劳人员信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 /**
  * @describe 军烈属信息导出
  * @param mbPopulations
  * @param fout
  * @param resp
  * @Return void
  * @Date 2022/2/21 15:20
  * @author shikun
  */
 public void exportByjunlieshu(List<MbPopulation> mbPopulations, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 4);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("军烈属人员统计信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
//   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
   sheet.setColumnWidth(4, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("军烈属人员统计信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(4);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名", "性别", "电话","家庭住址"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (mbPopulations != null) {
    int i = 1;
    for (int j = 0; j < mbPopulations.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出

     HSSFCell cell_4 = row3.createCell(0);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(mbPopulations.get(j).getSuperiorCode());

     HSSFCell cell_0 = row3.createCell(1);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(mbPopulations.get(j).getName());
     HSSFCell cell_1 = row3.createCell(2);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(mbPopulations.get(j).getSex());
     HSSFCell cell_2 = row3.createCell(3);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(mbPopulations.get(j).getTelephony());
     HSSFCell cell_3 = row3.createCell(4);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(mbPopulations.get(j).getNewaddress());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "军烈属人员统计信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public void exportBymedicalInsurance(List<MbPopulation> mbPopulations, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 3);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("医保人员信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
   sheet.setColumnWidth(2, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("医保人员信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(3);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名", "身份证号", "性别"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (mbPopulations != null) {
    int i = 1;
    for (int j = 0; j < mbPopulations.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出

     HSSFCell cell_3 = row3.createCell(0);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(mbPopulations.get(j).getSuperiorCode());

     HSSFCell cell_0 = row3.createCell(1);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(mbPopulations.get(j).getName());
     HSSFCell cell_1 = row3.createCell(2);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(mbPopulations.get(j).getIdnumber());
     HSSFCell cell_2 = row3.createCell(3);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(mbPopulations.get(j).getSex());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "医保人员信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }


 public void cheshi(List<TjInspectphysicalVo> tjInspectphysicalVos, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 4);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("体征信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 23*256);
//   sheet.setColumnWidth(4, 50*256);
//   sheet.setColumnWidth(5, 23*256);
//   sheet.setColumnWidth(6, 50*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("体征信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(4);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名","心率","阴指数","阳指数"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (tjInspectphysicalVos != null) {
    int i = 1;
    for (int j = 0; j < tjInspectphysicalVos.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出
     HSSFCell cell_0 = row3.createCell(0);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(tjInspectphysicalVos.get(j).getCodeName());
     HSSFCell cell_1 = row3.createCell(1);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(tjInspectphysicalVos.get(j).getName());
     HSSFCell cell_2 = row3.createCell(2);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(tjInspectphysicalVos.get(j).getSex());
     HSSFCell cell_3 = row3.createCell(3);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(tjInspectphysicalVos.get(j).getAge());
     HSSFCell cell_4 = row3.createCell(4);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(tjInspectphysicalVos.get(j).getChronic());

    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "体征信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public void finishbodycheckuplist(List<TjInspectphysicalVo> tjInspectphysicalVos, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 7);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("个体患者体检信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
   sheet.setColumnWidth(0, 23*256);
   sheet.setColumnWidth(4, 50*256);
   sheet.setColumnWidth(5, 23*256);
   sheet.setColumnWidth(6, 50*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("个体患者体检信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(7);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名","姓名","性别","年龄","慢病信息","身份证号","地址","体检日期"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (tjInspectphysicalVos != null) {
    int i = 1;
    for (int j = 0; j < tjInspectphysicalVos.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出
     HSSFCell cell_0 = row3.createCell(0);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(tjInspectphysicalVos.get(j).getCodeName());
     HSSFCell cell_1 = row3.createCell(1);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(tjInspectphysicalVos.get(j).getName());
     HSSFCell cell_2 = row3.createCell(2);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(tjInspectphysicalVos.get(j).getSex());
     HSSFCell cell_3 = row3.createCell(3);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(tjInspectphysicalVos.get(j).getAge());
     HSSFCell cell_4 = row3.createCell(4);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(tjInspectphysicalVos.get(j).getChronic());
     HSSFCell cell_5 = row3.createCell(5);
     cell_5.setCellStyle(cellStyle);
     cell_5.setCellValue(tjInspectphysicalVos.get(j).getIdnumber());
     HSSFCell cell_6 = row3.createCell(6);
     cell_6.setCellStyle(cellStyle);
     cell_6.setCellValue(tjInspectphysicalVos.get(j).getNewaddress());
     HSSFCell cell_7 = row3.createCell(7);
     cell_7.setCellStyle(cellStyle);
     cell_7.setCellValue(tjInspectphysicalVos.get(j).getInspectTime());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "个体患者体检信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public void exportBycreateTime(List<TjInspectphysicalVo> tjInspectphysicalVos, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 2);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("每日工作量统计信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("每日工作量统计信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(2);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   int totalAge = tjInspectphysicalVos.stream().mapToInt(TjInspectphysicalVo::getValue).sum();

   HSSFRow total = sheet.createRow(tjInspectphysicalVos.size()+3);
   HSSFCell total0 = total.createCell(0);
   total0.setCellStyle(cellStyle);
   total0.setCellValue("合计");

   HSSFCell total1 = total.createCell(1);
   total1.setCellStyle(cellStyle);
   total1.setCellValue("");

   HSSFCell total2 = total.createCell(2);
   total2.setCellStyle(cellStyle);
   total2.setCellValue(totalAge+"");

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名", "医生姓名", "体检人数"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (tjInspectphysicalVos != null) {
    int i = 1;
    for (int j = 0; j < tjInspectphysicalVos.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出
     HSSFCell cell_0 = row3.createCell(0);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(tjInspectphysicalVos.get(j).getCodeName());
     HSSFCell cell_1 = row3.createCell(1);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(tjInspectphysicalVos.get(j).getName());
     HSSFCell cell_2 = row3.createCell(2);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(tjInspectphysicalVos.get(j).getValue());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "每日工作量统计信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }


 public void exportBymonthgrouping(List<TjInspectphysicalVo> tjInspectphysicalVos, ServletOutputStream fout, HttpServletResponse resp) {
  try {
   //1.创建工作簿
   HSSFWorkbook workbook = new HSSFWorkbook();
   //1.1创建合并单元格对象
   CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 14);//起始行,结束行,起始列,结束列(输出列-1)
   //总标题
   HSSFCellStyle headStyle = createCellStyle(workbook, (short) 16, true, true, false);
   //时间
   HSSFCellStyle timeStyle = createCellStyle(workbook, (short) 10, true, true, false);
   //标题
   HSSFCellStyle colStyle = createCellStyle(workbook, (short) 10, true, true, true);
   //内容样式
   HSSFCellStyle cellStyle = createCellStyle(workbook, (short) 10, false, true, true);
   //2.创建工作表
   HSSFSheet sheet = workbook.createSheet("每月工作量统计信息");
   //2.1加载合并单元格对象
   sheet.addMergedRegion(callRangeAddress);
   //设置默认列宽
   sheet.setDefaultColumnWidth(15);
//   sheet.setColumnWidth(0, 13*256);
   sheet.setColumnWidth(1, 23*256);
//   sheet.setColumnWidth(2, 12*256);
//   sheet.setColumnWidth(3, 40*256);
   //3.创建行
   //3.1创建头标题行;并且设置头标题
   HSSFRow row = sheet.createRow(0);
   HSSFCell cell = row.createCell(0);
   //加载单元格样式
   cell.setCellStyle(headStyle);
   //文件标题
   cell.setCellValue("每月工作量统计信息");

   HSSFRow rowsan = sheet.createRow(1);
   //导出文件第2行 时间 同结束列一样
   HSSFCell cellsan2 = rowsan.createCell(14);
   cellsan2.setCellStyle(timeStyle);
   cellsan2.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

   //3.2创建列标题;并且设置列标题
   HSSFRow row2 = sheet.createRow(2);
   String[] titles = {"村名", "医生", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月", "合计"};//""为占位字符串
   for (int i = 0; i < titles.length; i++) {
    HSSFCell cell2 = row2.createCell(i);
    //加载单元格样式
    cell2.setCellStyle(colStyle);
    cell2.setCellValue(titles[i]);
   }
   //4.操作单元格;将用户列表写入excel
   if (tjInspectphysicalVos != null) {
    int i = 1;
    for (int j = 0; j < tjInspectphysicalVos.size(); j++) {
     //创建数据行,前面有两行,头标题行和列标题行+日期
     HSSFRow row3 = sheet.createRow(j + 3);//从第4行开始输出
     HSSFCell cell_0 = row3.createCell(1);
     cell_0.setCellStyle(cellStyle);
     cell_0.setCellValue(tjInspectphysicalVos.get(j).getName());
     HSSFCell cell_1 = row3.createCell(0);
     cell_1.setCellStyle(cellStyle);
     cell_1.setCellValue(tjInspectphysicalVos.get(j).getCodeName());
     HSSFCell cell_2 = row3.createCell(2);
     cell_2.setCellStyle(cellStyle);
     cell_2.setCellValue(tjInspectphysicalVos.get(j).getValu1());

     HSSFCell cell_3 = row3.createCell(3);
     cell_3.setCellStyle(cellStyle);
     cell_3.setCellValue(tjInspectphysicalVos.get(j).getValu2());

     HSSFCell cell_4 = row3.createCell(4);
     cell_4.setCellStyle(cellStyle);
     cell_4.setCellValue(tjInspectphysicalVos.get(j).getValu3());

     HSSFCell cell_5 = row3.createCell(5);
     cell_5.setCellStyle(cellStyle);
     cell_5.setCellValue(tjInspectphysicalVos.get(j).getValu4());

     HSSFCell cell_6 = row3.createCell(6);
     cell_6.setCellStyle(cellStyle);
     cell_6.setCellValue(tjInspectphysicalVos.get(j).getValu5());

     HSSFCell cell_7 = row3.createCell(7);
     cell_7.setCellStyle(cellStyle);
     cell_7.setCellValue(tjInspectphysicalVos.get(j).getValu6());

     HSSFCell cell_8 = row3.createCell(8);
     cell_8.setCellStyle(cellStyle);
     cell_8.setCellValue(tjInspectphysicalVos.get(j).getValu7());

     HSSFCell cell_9 = row3.createCell(9);
     cell_9.setCellStyle(cellStyle);
     cell_9.setCellValue(tjInspectphysicalVos.get(j).getValu8());

     HSSFCell cell_10 = row3.createCell(10);
     cell_10.setCellStyle(cellStyle);
     cell_10.setCellValue(tjInspectphysicalVos.get(j).getValu9());

     HSSFCell cell_11 = row3.createCell(11);
     cell_11.setCellStyle(cellStyle);
     cell_11.setCellValue(tjInspectphysicalVos.get(j).getValu10());

     HSSFCell cell_12 = row3.createCell(12);
     cell_12.setCellStyle(cellStyle);
     cell_12.setCellValue(tjInspectphysicalVos.get(j).getValu11());

     HSSFCell cell_13 = row3.createCell(13);
     cell_13.setCellStyle(cellStyle);
     cell_13.setCellValue(tjInspectphysicalVos.get(j).getValu12());

     HSSFCell cell_14 = row3.createCell(14);
     cell_14.setCellStyle(cellStyle);
     cell_14.setCellValue(tjInspectphysicalVos.get(j).getSum());
    }
   }
   //5.输出
   try {
    //下载文件名
    String fileName = "每月工作量统计信息";
    //设置文件名以及格式
    resp.addHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName + ".xls", "UTF-8"));
    //写入输出出去
    workbook.write(fout);
    fout.flush();
    fout.close();
    workbook.close();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    try {
     if (workbook != null) {
      workbook.close();
     }
     if (fout != null) {
      fout.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   System.out.println("导出成功");
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 /**
  * @param workbook
  * @param fontsize
  * @param flag
  * @param flag1
  * @param flag2
  * @describe 单元格样式 不用动
  * @Return org.apache.poi.hssf.usermodel.HSSFCellStyle
  * @Date 2021/12/1 9:11
  * @author shikun
  */
 private static HSSFCellStyle createCellStyle(HSSFWorkbook workbook, short fontsize, boolean flag, boolean flag1, boolean flag2) {
  // TODO Auto-generated method stub
  HSSFCellStyle style = workbook.createCellStyle();
  //是否水平居中
  if (flag1) {
   style.setAlignment(HorizontalAlignment.CENTER);//水平居中
  }
  if (flag2) {
   style.setBorderBottom(BorderStyle.THIN); //下边框
   style.setBorderLeft(BorderStyle.THIN);//左边框
   style.setBorderTop(BorderStyle.THIN);//上边框
   style.setBorderRight(BorderStyle.THIN);//右边框
  }
  style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
  style.setWrapText(true);
  //创建字体
  HSSFFont font = workbook.createFont();
  //是否加粗字体
  if (flag) {
   //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   font.setBold(true);
  }
  font.setFontHeightInPoints(fontsize);
  //加载字体
  style.setFont(font);
  return style;
 }
}
